package sctu.edu.java.year2016.team06.yuweimei.day20160612.chapter15_1;

/**
 * 尝试定义一个继承Thread类的类，并覆盖run()方法。在run方法中每隔100毫秒打印一句话。
 * Created by asus on 2016/6/13.
 */
public class ThreadInherit extends Thread {
    int i;

    @Override
    public void run() {    //覆盖run（）方法
        Test();
    }


    private void Test() {
        for (i = 0; i < 200; i++) {


            System.out.println("面朝大海 ，春暖花开！");
            System.out.println("隔了0.1秒之后");     //for循环打印

            try {
                Thread.sleep(100);     //设置休眠时间
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }


    public static void main(String[] args) {
        ThreadInherit threadInherit = new ThreadInherit();
        threadInherit.run();
    }
}





